package com.qfmy.app.service.impl.novel;

import com.qfmy.app.mapper.novel.AuthorMapper;
import com.qfmy.app.service.novel.AuthorService;
import com.qfmy.app.vo.novel.AuthorVo;
import com.qfmy.model.entity.novel.Author;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author 清风明月
 * @Package com.qfmy.app.service.impl.novel
 * @date 2025/4/16
 * @description 作者
 */
@Service
@SuppressWarnings("all")
public class AuthorServiceImpl implements AuthorService {

    /**
     * 注入mapper
     */
    @Autowired
    private AuthorMapper authorMapper;

    /**
     * 根据作者名查询作者
     * @param authorName
     * @return
     */
    @Override
    public AuthorVo getAuthorByName(String authorName) {
        Author author = authorMapper.getAuthorByName(authorName);
        if(author != null){
            //进行对象拷贝
            AuthorVo authorVo = new AuthorVo();
            BeanUtils.copyProperties(author,authorVo);
            return authorVo;
        }
        return new AuthorVo();
    }
}
